<?php
class BbsAction extends Action {	
	
	function post(){
		$this->getDisplay('post');
	}
	
	
	function reply(){
		$this->getDisplay('reply');
	}
	
	
	private function getDisplay($type){
		if($type=='post'){
			$data = D('Topic','bbs')->where('uid='.$this->mid)->order('cTime DESC')->findpage(30);
		}else{
			$count = M()->query("SELECT count( distinct a.id ) as c FROM ".C('DB_PREFIX')."bbs_topic a LEFT JOIN ".C('DB_PREFIX')."bbs_post b ON a.id=b.tid WHERE a.uid<>{$this->mid} AND b.istopic=0 AND b.uid={$this->mid}");
			$data = D('Topic','bbs')->table( C('DB_PREFIX')."bbs_topic a LEFT JOIN ".C('DB_PREFIX')."bbs_post b ON a.id=b.tid")->field('distinct(a.id),a.*')->where("a.uid<>{$this->mid} AND b.istopic=0 AND b.uid=".$this->mid)->order('a.rTime DESC')->findpage(30,$count[0]['c']);
		}
		$this->assign( $data ); 
		$this->assign('type',$type);	
		$this->display('index');
	}
}
?>